// pages/components/ArticleList/ArticleList.js

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item:{
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
   
  },

  /**
   * 组件的方法列表
   */
  methods: {
    cannel(){
         console.log(123)
         this.triggerEvent('cannel')
    },
     //更新用户信息
    
    bindGetUserInfo (e) {
      console.log(e)
    console.log(e.detail.userInfo);
    if (!e.detail.userInfo) {
       wx.showToast({
          title: '需要授权之后才可以享受服务',
          icon:'none',
          duration: 2000
        })
      return
    }
    var userInfo= wx.getStorageSync('userInfo');
    var address= wx.getStorageSync('address');
   

    var json=e.detail.userInfo;
    json.openid=userInfo.openid;
    if (address) {
       json.city=address.city;
        json.province=address.province;
    }
    console.log('userInfo')
     console.log(userInfo)
    var _self=this;
     wx.request({
            url:getApp().globalData.baseUrl+'/wx/user/update',
            method:"post",
            header: {
                'openid':userInfo.openid, //公用请求头
                'content-type': 'application/json'
            },
            data:e.detail.userInfo,
            success: function(res) {
            if(res.data.code==200){
               wx.setStorageSync('userInfo',json);
               _self.triggerEvent('loginSuccess')
            }  
         }
       })
    }
  }
})
